#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=50 

DEST=
DEFAULT=$DEST/etc/default/asterisk
OPTIONS=""

start() {
	[ -f $DEFAULT ] && . $DEFAULT
	[ -d $DEST/var/run/asterisk ] || mkdir -p $DEST/var/run/asterisk
	[ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk
	[ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk
        [ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
        [ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf /var/spool/asterisk/astdb $DEST/usr/lib/asterisk/astdb
	$DEST/usr/sbin/asterisk $OPTIONS
}

stop() {
	[ -f $DEST/var/run/asterisk/asterisk.pid ] && kill $(cat $DEST/var/run/asterisk/asterisk.pid) >/dev/null 2>&1
}
